﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class ZCAllList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindTFSQGridView();
            }
        }

        protected void TFSQGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItem != null)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#FFFF99'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                ((Label)e.Row.FindControl("IDLbl")).Text = (e.Row.RowIndex + 1).ToString();
            }
        }

        protected void TFSQGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < TFSQGridView.PageCount)
            {
                TFSQGridView.PageIndex = e.NewPageIndex;
            }
            
            BindTFSQGridView();
        }

        private void BindTFSQGridView()
        {
            ZCService service = new ZCService();
            TFSQGridView.DataSource = service.GetAllApplications(Request.QueryString["Type"]);
            TFSQGridView.DataBind();
        }

        protected void viewLinkButton_click(object sender, EventArgs e)
        {
            string applicationid = ((LinkButton)sender).CommandArgument;
            Response.Redirect(string.Format("ZCDetail.aspx?{0}={1}&Type={2}", Constants.QUERYSTR_APPLICATION_ID, applicationid, Request.QueryString["Type"]));
        }
    }
}
